//
//  PrescriptionOrderTrackingNumberCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2021/8/13.
//  Copyright © 2021 QDSG. All rights reserved.
//

import UIKit

protocol PrescriptionOrderTrackingNumberCellDelegate: NSObjectProtocol {
    func didEndEditing(_ text: String, at indexPath: IndexPath)
}

class PrescriptionOrderTrackingNumberCell: UITableViewCell, UITextFieldDelegate {
    
    weak var delegate: PrescriptionOrderTrackingNumberCellDelegate?
    
    private var indexPath: IndexPath?

    func update(at indexPath: IndexPath) {
        self.indexPath = indexPath
        titleLabel.text = indexPath.row == 0 ? "快递公司" : "快递单号"
    }
    
    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var textField: UITextField! {
        didSet {
            textField.delegate = self
        }
    }
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        guard let indexPath = indexPath else { return }
        
        delegate?.didEndEditing(textField.text!, at: indexPath)
    }
    
}
